package com.huitone.smspfm.socket.protocol.sgip.constant;

import java.util.HashMap;
import java.util.Map;

import com.bin.common.utils.ArrayUtils;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ActiveTest;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ActiveTestResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Bind;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.BindResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Deliver;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.DeliverResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.IBody;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report2;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Report2Resp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.ReportResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Resp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit2;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.Submit2Resp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.SubmitResp;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.UnBind;
import com.huitone.smspfm.socket.protocol.sgip.message.msgbody.UnBindResp;

/**   
* @Title CommandID.java 
* @Package com.huitone.smspfm.socket.protocol.sgip.constant 
* @Description TODO(用一句话描述该文件做什么) 
* @author ybliang   
* @date 2017年3月23日 下午2:18:42 
* @version V1.0   
*/
public class CommandID {

	public static final long SGIP_BIND = 0x1L;
	
	public static final String SGIP_BIND_STR = "1";
	
	public static final long SGIP_BIND_RESP = 0x80000001L;
	
	public static final String SGIP_BIND_RESP_STR = "2147483649";
	
	public static final long SGIP_UNBIND = 0x2L;
	
	public static final String SGIP_UNBIND_STR = "2";
	
	public static final long SGIP_UNBIND_RESP = 0x80000002L;
	
	public static final String SGIP_UNBIND_RESP_STR = "2147483650";
	
	public static final long SGIP_SUBMIT	 = 0x3L;
	
	public static final String SGIP_SUBMIT_STR = "3";
	
	public static final long SGIP_SUBMIT_RESP = 0x80000003L;
	
	public static final String SGIP_SUBMIT_RESP_STR = "2147483651";
	
	public static final long SGIP_DELIVER = 0x4L;
	
	public static final String SGIP_DELIVER_STR = "4";
	
	public static final long SGIP_DELIVER_RESP = 0x80000004L;
	
	public static final String SGIP_DELIVER_RESP_STR = "2147483652";
	
	public static final long SGIP_REPORT = 0x5L;
	
	public static final String SGIP_REPORT_STR = "5";
	
	public static final long SGIP_REPORT_RESP = 0x80000005L;
	
	public static final String SGIP_REPORT_RESP_STR = "2147483653";
	
	public static final long SGIP_ACTIVE_TEST = 0x8L;
	
	public static final String SGIP_ACTIVE_TEST_STR = "8";
	
	public static final long SGIP_ACTIVE_TEST_RESP = 0x80000008L;
	
	public static final String SGIP_ACTIVE_TEST_RESP_STR = "2147483656";
	
	public static final long SGIP_SUBMIT2 = 0x9L;
	
	public static final String SGIP_SUBMIT2_STR = "9";
	
	public static final long SGIP_SUBMIT2_RESP = 0x80000009L;
	
	public static final String SGIP_SUBMIT2_RESP_STR = "2147483657";
	
	public static final long SGIP_REPORT2 = 0xAL;
	
	public static final String SGIP_REPORT2_STR = "10";
	
	public static final long SGIP_REPORT2_RESP = 0x8000000AL;
	
	public static final String SGIP_REPORT2_RESP_STR = "2147483658";
	
	//public static final long SGIP_DELIVER2 = 0xBL;
	
	//public static final String SGIP_DELIVER2_STR = "11";
	
	//public static final long SGIP_DELIVER2_RESP = 0x8000000BL;
	
	//public static final String SGIP_DELIVER2_RESP_STR = "2147483659";
	
	/*public static final long[] commandIDs = {SGIP_BIND, SGIP_BIND_RESP, SGIP_UNBIND, SGIP_UNBIND_RESP, SGIP_SUBMIT, SGIP_SUBMIT_RESP, 
			SGIP_DELIVER, SGIP_DELIVER_RESP, SGIP_REPORT, SGIP_REPORT_RESP, SGIP_ACTIVE_TEST, SGIP_ACTIVE_TEST_RESP, SGIP_SUBMIT2, SGIP_SUBMIT2_RESP,
			SGIP_REPORT2, SGIP_REPORT2_RESP, SGIP_DELIVER2, SGIP_DELIVER2_RESP};*/
	
	public static final long[] commandIDs_subt = {SGIP_BIND, SGIP_UNBIND, SGIP_SUBMIT, SGIP_DELIVER, SGIP_REPORT, SGIP_ACTIVE_TEST, SGIP_SUBMIT2, SGIP_REPORT2};
	
	public static final long[] commandIDs_resp = {SGIP_BIND_RESP, SGIP_UNBIND_RESP, SGIP_SUBMIT_RESP, SGIP_DELIVER_RESP, SGIP_REPORT_RESP, SGIP_ACTIVE_TEST_RESP, SGIP_SUBMIT2_RESP, 
			SGIP_REPORT2_RESP};
	
	public static final long[] commandIDs = ArrayUtils.addAll(commandIDs_subt, commandIDs_resp);
	
	public static enum commandIDem {SGIP_BIND, SGIP_BIND_RESP, SGIP_UNBIND, SGIP_UNBIND_RESP, SGIP_SUBMIT, SGIP_SUBMIT_RESP, 
		SGIP_DELIVER, SGIP_DELIVER_RESP, SGIP_REPORT, SGIP_REPORT_RESP, SGIP_ACTIVE_TEST, SGIP_ACTIVE_TEST_RESP, SGIP_SUBMIT2, SGIP_SUBMIT2_RESP,
		SGIP_REPORT2, SGIP_REPORT2_RESP, SGIP_DELIVER2, SGIP_DELIVER2_RESP}
	
	public static Map<Class<? extends IBody>, Long> GetCommandIdByEntityClass = new HashMap<Class<? extends IBody>, Long>() {

		private static final long serialVersionUID = 1L;
		
		{
			put(BindResp.class, SGIP_BIND_RESP);
			put(UnBindResp.class, SGIP_UNBIND_RESP);
			put(SubmitResp.class, SGIP_SUBMIT_RESP);
			put(DeliverResp.class, SGIP_DELIVER_RESP);
			put(ReportResp.class, SGIP_REPORT_RESP);
			put(ActiveTestResp.class, SGIP_ACTIVE_TEST_RESP);
			put(Submit2Resp.class, SGIP_SUBMIT2_RESP);
			put(Report2Resp.class, SGIP_REPORT2_RESP);
			put(Bind.class, SGIP_BIND);
			put(UnBind.class, SGIP_UNBIND);
			put(Submit.class, SGIP_SUBMIT);
			put(Deliver.class, SGIP_DELIVER);
			put(Report.class, SGIP_REPORT);
			put(ActiveTest.class, SGIP_ACTIVE_TEST);
			put(Submit2.class, SGIP_SUBMIT2);
			put(Report2.class, SGIP_REPORT2);
		}
	};
	
	public static Map<Long, Class<? extends Resp>> commandIDRespClass = new HashMap<Long, Class<? extends Resp>>() {

		private static final long serialVersionUID = 1L;
		
		{
			put(SGIP_BIND, BindResp.class);
			put(SGIP_UNBIND, UnBindResp.class);
			put(SGIP_SUBMIT, SubmitResp.class);
			put(SGIP_DELIVER, DeliverResp.class);
			put(SGIP_REPORT, ReportResp.class);
			put(SGIP_ACTIVE_TEST, ActiveTestResp.class);
			put(SGIP_SUBMIT2, Submit2Resp.class);
			put(SGIP_REPORT2, Report2Resp.class);
		}
	};
	
	public static Map<Long, Long> commandIDRespID = new HashMap<Long,Long>() {

		private static final long serialVersionUID = 1L;
		
		{
			put(SGIP_BIND, SGIP_BIND_RESP);
			put(SGIP_UNBIND, SGIP_UNBIND_RESP);
			put(SGIP_SUBMIT, SGIP_SUBMIT_RESP);
			put(SGIP_DELIVER, SGIP_DELIVER_RESP);
			put(SGIP_REPORT, SGIP_REPORT_RESP);
			put(SGIP_ACTIVE_TEST, SGIP_ACTIVE_TEST_RESP);
			put(SGIP_SUBMIT2, SGIP_SUBMIT2_RESP);
			put(SGIP_REPORT2, SGIP_REPORT2_RESP);
		}
		
	};
	
	public static Map<Long, CommandID.commandIDem> commandIDmap = new HashMap<Long, CommandID.commandIDem>(){
		private static final long serialVersionUID = 1L;

	{
		put(SGIP_BIND, commandIDem.SGIP_BIND);
		put(SGIP_BIND_RESP, commandIDem.SGIP_BIND_RESP);
		put(SGIP_UNBIND, commandIDem.SGIP_UNBIND);
		put(SGIP_UNBIND_RESP, commandIDem.SGIP_UNBIND_RESP);
		put(SGIP_SUBMIT, commandIDem.SGIP_SUBMIT);
		put(SGIP_SUBMIT_RESP, commandIDem.SGIP_SUBMIT_RESP);
		put(SGIP_DELIVER, commandIDem.SGIP_DELIVER);
		put(SGIP_DELIVER_RESP, commandIDem.SGIP_DELIVER_RESP);
		put(SGIP_REPORT, commandIDem.SGIP_REPORT);
		put(SGIP_REPORT_RESP, commandIDem.SGIP_REPORT_RESP);
		put(SGIP_ACTIVE_TEST, commandIDem.SGIP_ACTIVE_TEST);
		put(SGIP_ACTIVE_TEST_RESP, commandIDem.SGIP_ACTIVE_TEST_RESP);
		put(SGIP_SUBMIT2, commandIDem.SGIP_SUBMIT2);
		put(SGIP_SUBMIT2_RESP, commandIDem.SGIP_SUBMIT2_RESP);
		put(SGIP_REPORT2, commandIDem.SGIP_REPORT2);
		put(SGIP_REPORT2_RESP, commandIDem.SGIP_REPORT2_RESP);
	}};
	
	public static boolean hasCommandID(long commandID) {
		
		boolean result = false;
		
		for (long id:commandIDs) {
			if (id == commandID) {
				result = true;
				break;
			}
		}
		
		return result;
	}
	
	public static commandIDem getCommandIDem(long commandID) {
		return commandIDmap.get(commandID);
	}
	
	public static Class<? extends Resp> getRespClass(long commandID) {
		return commandIDRespClass.get(commandID);
	}
	
	public static long getRespID(long commandID) {
		return commandIDRespID.get(commandID);
	}
}
